package com.xinqi.modules.mq.delay.dao;

import com.xinqi.modules.mq.delay.entity.MqDelayMessageEntity;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;

public class MqDelayMessageRowMapper implements RowMapper<MqDelayMessageEntity> {

    @Override
    public MqDelayMessageEntity mapRow(ResultSet rs, int rowNum) throws SQLException {
        MqDelayMessageEntity message = new MqDelayMessageEntity();
        message.setId(rs.getLong("id"));
        Timestamp createTime = rs.getTimestamp("create_time");
        message.setCreateTime(createTime == null ? null : createTime.toLocalDateTime());
        Timestamp updateTime = rs.getTimestamp("update_time");
        message.setUpdateTime(updateTime == null ? null : updateTime.toLocalDateTime());
        message.setMqId(rs.getString("mq_id"));
        message.setMqKey(rs.getString("mq_key"));
        Timestamp arrivalTime = rs.getTimestamp("arrival_time");
        message.setArrivalTime(arrivalTime == null ? null : arrivalTime.toLocalDateTime());
        message.setStatus(rs.getInt("status"));
        message.setIsDel(rs.getInt("is_del"));
        return message;
    }
}
